package entities;

import java.io.Serializable;
import javax.persistence.*;

import java.util.Date;
import java.util.List;

/**
 * The persistent class for the examine_detail database table.
 * 
 */
@Entity
@Table(name = "examine_detail")
@org.eclipse.persistence.annotations.Cache
public class ExamineDetail implements Serializable {
	private static final long serialVersionUID = 1L;
	private int idExamine;
	private Date appointmentDay;
	private String disease;
	private Date examineDay;
	private PatientDetail patientDetail;
	private Doctor doctor;
	private List<LabServiceDetail> labServiceDetails;
	private List<MedicineDetail> medicineDetails;

	public ExamineDetail() {
	}

	public ExamineDetail(Date appointmentDay, PatientDetail patientDetail) {
		super();
		this.appointmentDay = appointmentDay;
		this.patientDetail = patientDetail;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(unique = true, nullable = false)
	public int getIdExamine() {
		return this.idExamine;
	}

	public void setIdExamine(int idExamine) {
		this.idExamine = idExamine;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable = false)
	public Date getAppointmentDay() {
		return this.appointmentDay;
	}

	public void setAppointmentDay(Date appointmentDay) {
		this.appointmentDay = appointmentDay;
	}

	@Column(length = 200)
	public String getDisease() {
		return this.disease;
	}

	public void setDisease(String disease) {
		this.disease = disease;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getExamineDay() {
		return this.examineDay;
	}

	public void setExamineDay(Date examineDay) {
		this.examineDay = examineDay;
	}

	// bi-directional many-to-one association to PatientDetail
	@ManyToOne
	@JoinColumn(name = "idPatientDetail", nullable = false)
	public PatientDetail getPatientDetail() {
		return this.patientDetail;
	}

	public void setPatientDetail(PatientDetail patientDetail) {
		this.patientDetail = patientDetail;
	}

	// bi-directional many-to-one association to Doctor
	@ManyToOne
	@JoinColumn(name = "idDoctor")
	public Doctor getDoctor() {
		return this.doctor;
	}

	public void setDoctor(Doctor doctor) {
		this.doctor = doctor;
	}

	// bi-directional many-to-one association to LabServiceDetail
	@OneToMany(mappedBy = "examineDetail", fetch = FetchType.EAGER)
	public List<LabServiceDetail> getLabServiceDetails() {
		return this.labServiceDetails;
	}

	public void setLabServiceDetails(List<LabServiceDetail> labServiceDetails) {
		this.labServiceDetails = labServiceDetails;
	}

	// bi-directional many-to-one association to MedicineDetail
	@OneToMany(mappedBy = "examineDetail", fetch = FetchType.EAGER)
	public List<MedicineDetail> getMedicineDetails() {
		return this.medicineDetails;
	}

	public void setMedicineDetails(List<MedicineDetail> medicineDetails) {
		this.medicineDetails = medicineDetails;
	}

	@Override
	public String toString() {
		if (examineDay != null) {
			return this.getClass().getName() + "[ " + idExamine + " | " + appointmentDay.toString()
					+ " | " + disease + " | " + examineDay.toString() + " | "
					+ patientDetail.getIdPatientDetail() + " | " + doctor.getIdDoctor() + " ]";
		}
		return this.getClass().getName() + "[ " + idExamine + " | " + appointmentDay.toString()
				+ " | " + patientDetail.getIdPatientDetail() + " ]";
	}

}